#include"BlockQueue.hpp"
#include<time.h>
#include<unistd.h>
void* Buy(void* argv)
{
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(argv);
    while(1)
    {
        int data = 0;
        bq->Pop(&data);
        cout << "Consumer->" << data << endl;
        sleep(1);
    }
}
void* Put(void* argv)
{
    srand(time(nullptr));
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(argv);
    while(1)
    {
        int data = rand() % 10 + 1;
        bq->Equeue(data);
        cout << "Productor->" << data << endl;
    }
}
int main()
{
    BlockQueue<int> *bq = new BlockQueue<int>();
    pthread_t c, p;
    pthread_create(&c, nullptr, Buy, bq);
    pthread_create(&p, nullptr, Put, bq);
    pthread_join(c,nullptr);
    pthread_join(p,nullptr);
    return 0;
}